import Types from "../actionTypes";

let initState = {
  cate_code: "",
  allMeasure: [
    {
      code: "01",
      name: "根"
    }, {
      code: "02",
      name: "个"
    }, {
      code: "03",
      name: "吨"
    }, {
      code: "04",
      name: "把"
    }, {
      code: "05",
      name: "件"
    }, {
      code: "06",
      name: "张"
    }, {
      code: "07",
      name: "包"
    }, {
      code: "08",
      name: "米"
    }, {
      code: "09",
      name: "节"
    }, {
      code: "10",
      name: "条"
    }, {
      code: "11",
      name: "套"
    }, {
      code: "12",
      name: "公斤"
    }, {
      code: "13",
      name: "平方米"
    }, {
      code: "14",
      name: "台"
    }, {
      code: "15",
      name: "盒"
    }, {
      code: "16",
      name: "卷"
    }, {
      code: "17",
      name: "块"
    }, {
      code: "18",
      name: "袋"
    }, {
      code: "19",
      name: "对"
    }, {
      code: "20",
      name: "片"
    }, {
      code: "21",
      name: "支"
    }, {
      code: "22",
      name: "瓶"
    }, {
      code: "23",
      name: "桶"
    }, {
      code: "24",
      name: "升"
    }, {
      code: "25",
      name: "箱"
    }, {
      code: "26",
      name: "斤"
    }, {
      code: "27",
      name: "顶"
    }, {
      code: "28",
      name: "千克"
    }, {
      code: "29",
      name: "管"
    }, {
      code: "30",
      name: "本"
    }, {
      code: "31",
      name: "副"
    }, {
      code: "32",
      name: "双"
    }, {
      code: "33",
      name: "批"
    }, {
      code: "34",
      name: "次"
    }
  ], // 单位
  allBrands: [],
  codeLibraryInfo: [],
  isSelected: false,
  currentPage: 1,
  isModify: false, //   是点击的修改还是点击的新增   isModify:true ==>修改 isModifg:false ==> 新增
  aData: {}
};

export default (state = initState, action) => {
  const newState = JSON.parse(JSON.stringify(state));
  switch (action.type) {

    case Types.CATE_CODE:
      newState.cate_code = action.cate_code;
      return newState;

    case Types.GET_ALL_BRAND:
      newState.allBrands = action.list;
      return newState;
    case Types.GET_CODELIBRARY_INFO:
      newState.codeLibraryInfo = action.value;
      return newState;

    case Types.IS_SELECTED:
      newState.isSelected = action.value;
      return newState;

    case Types.CURRENT_PAGE:
      newState.currentPage = action.value;
      return newState;

    case Types.IS_CODELIBRARY_MODIFY:
      newState.isModify = action.boobean;
      return newState;

    case Types.GET_SINGLE_CODE:
      newState.aData = action.data;
      return newState;

    default:
      console.log("Types no match in codeLibrary.js ....");
  }
  return state;
}
